<?php
use App\Http\Controllers\Common\CommonApi;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

//============= 测试路由 =============
// Route::get('test', 'Admin\Categories\Api\CategoriesApi@getCategoriesList');

// Route::get('test', function () {

//     return session('uploadPic');
// });

Route::post('/upload', 'Admin\Index\IndexController@upload');



//============= 前台路由 =============
//博客前台首页
Route::get('/', 'Home\Index\IndexController@index');

Route::get('article/{id}', 'Home\Articles\ArticlesController@articleDetail');



//============= 后台路由 =============
Route::prefix('admin')->middleware(['admin.auth'])->group(function () {

    //后台首页
    Route::get('/', 'Admin\Articles\ArticlesController@articleList');

    //******文章管理模块******
    //加载博客列表页面
    Route::get('article-list', 'Admin\Articles\ArticlesController@articleList');
    //加载写博客页面
    Route::get('article-add', 'Admin\Articles\ArticlesController@articleAdd');
    //执行写博客
    Route::post('article-store', 'Admin\Articles\ArticlesController@doArticleAdd');
    //加载编辑博客页面
    Route::get('article-edit/{id}', 'Admin\Articles\ArticlesController@articleEdit');
    //执行写博客
    Route::post('article-update', 'Admin\Articles\ArticlesController@doArticleUpdate');

    //******分类与标签管理模块******
    //加载分类列表页面
    Route::get('category-list', 'Admin\Categories\CategoriesController@categoryList');
    //加载新增分类页面
    Route::get('category-add', 'Admin\Categories\CategoriesController@categoryAdd');
    //执行分类新增操作
    Route::post('category-store', 'Admin\Categories\CategoriesController@categoryStore');
    //加载编辑分类页面
    Route::get('category-edit/{id}', 'Admin\Categories\CategoriesController@categoryEdit');
    //执行修改分类操作
    Route::post('category-update', 'Admin\Categories\CategoriesController@categoryUpdate');
    Route::post('category-del/{id}', 'Admin\Categories\CategoriesController@categoryDel');


    //加载标签列表页面
    Route::resource('tag', 'Admin\Tags\TagsResourceController');
    // Route::get('tag-list', 'Admin\Tags\TagsController@tagList');


    //===============测试用====================
    Route::get('test', 'Admin\Index\IndexController@test');
    Route::get('serve', 'Admin\UEditorController@serve');

});


//============= 后台登陆/登出路由 =============
Route::get('login', function () {
    
    return view('Admin/Login/login');
});//登陆

Route::post('adminlogin', 'Admin\Login\LoginController@login'); //执行登陆
Route::get('/changecode', 'Common\CommonApi@buildCode');    //刷新/生成二维码
Route::post('/checkcode', 'Admin\Login\LoginController@checkCode'); //检验二维码
Route::get('logout', 'Admin\Login\LoginController@logout'); //登出
//哈哈~~~!~~呵呵~~~
//哈哈~~~